<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
<meta charset="UTF-8">
<title>课程添加</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<link rel="stylesheet" href="../../static/lib/layui/css/layui.css" th:href="@{/lib/layui/css/layui.css}" media="all">
<script src="../../static/lib/layui/layui.js" th:src="@{/lib/layui/layui.js}" charset="utf-8"></script>
<script src="../../static/lib/jquery/jquery-3.2.1.min.js" th:src="@{/lib/jquery/jquery-3.2.1.min.js}"></script>
<script src="../../static/js/common/public.js" th:src="@{/js/common/public.js}"></script>
<style type="text/css">
    .form-padding {
        padding: 10px;
        width: 400px;
    }

    .upload-file {
        margin-left: 80px;
        width: 200px;
        height: 200px;
        text-align: center;
        display: inline-block;
        line-height: 200px;
    }
    .form-padding div.layui-input-inline{
        width: 220px;
    }
</style>
</head>
<body>
<form class="layui-form form-padding" id="add-form">
    <input name="courseId" th:value="${courseId}" type="hidden" id="courseId">
</form>
<div class="layui-btn upload upload-file" id="#upload">点击或拖拽至此上传缩略图</div>
<script type="application/javascript" th:inline="none">
    (function () {
        let layer;
        layui.use('element', function () {
            var element = layui.element;
        });
        layui.use('form', function () {
            /*var form = layui.form;
            //监听提交
            form.on('submit(formDemo)', function (data) {
                layer.msg(JSON.stringify(data.field));
                return false;
            });*/
        });
        layui.use('layer', function () {
            layer = layui.layer;
        });
        layui.use('upload', function () {
            var upload = layui.upload; //得到 upload 对象
            upload.render({
                elem: '.upload'
                , url: '/interface/course/insertVideo'
                , bindAction: '#upload'
                , done: function (res, index, upload) {
                    var item = this.item;
                    layer.msg("上传成功")
                }
                , data: {courseId:$('#courseId').val()}
                , drag: true
                , accept: 'file'
                // ,auto:false
            })
        })
    })()

</script>
</body>
</html>